﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace  LINQToolKit.Douban.Entities
{
    public class Movie : Subject
    {
        private const string YEAR_KEY = "year";
        private const string DIRECTOR_KEY = "director";
        private const string LANGUAGE_KEY = "language";
        private const string SITE_KEY = "site";
        private const string IMDB_KEY = "imdb";
        private const string COUNTRY_KEY = "country";
        private const string CAST_KEY = "cast";

        public int Year
        {
            get 
            {
                string tmp = base.GetAttribute(YEAR_KEY);
                return string.IsNullOrEmpty(tmp) ? 0 : Convert.ToInt32(tmp);
            }
            set { base.SetAttribute(YEAR_KEY, value.ToString()); }
        }

        public string Director
        {
            get { return base.GetAttribute(DIRECTOR_KEY); }
            set { base.SetAttribute(DIRECTOR_KEY, value); }
        }

        public string Language 
        {
            get { return base.GetAttribute(LANGUAGE_KEY); }
            set { base.SetAttribute(LANGUAGE_KEY, value); }
        }

        public string Site
        {
            get { return base.GetAttribute(SITE_KEY); }
            set { base.SetAttribute(SITE_KEY, value); }
        }

        public string IMDB
        {
            get { return base.GetAttribute(IMDB_KEY); }
            set { base.SetAttribute(IMDB_KEY, value); }
        }

        public string Country
        {
            get { return base.GetAttribute(COUNTRY_KEY); }
            set { base.SetAttribute(COUNTRY_KEY, value); }
        }

        public IList<string> Casts
        {
            get { return base.GetAttributes(CAST_KEY); }
        }

        public bool HasCast(string name)
        {
            if (this.Casts != null)
            {
                return this.Casts.Contains(name);
            }

            return false;
        }
    }
}
